<?php

/**
 * 积分记录
 */

namespace app\member\common;

class PointsCommon extends \app\member\common\MemberCommon {

    protected function index() {
        $this->setMeta('积分记录');
        $this->pageInfo['name'] = '积分记录';

        $urlParam = [];
        $where = [];
        $type = request('get', 'type', 0, 'intval');

        $urlParam['type'] = $type;
        if ($type == 1) {
            $where['A.type'] = 1;
        }
        if ($type == 2) {
            $where['A.type'] = 0;
        }

        $pageLimit = 10;
        $where['A.account_id'] = $this->userInfo['points_account_id'];

        $model = target('member/PointsLog');
        $count = $model->countList($where);
        $pageData = $this->pageData($count, $pageLimit, $urlParam);
        $list = $model->loadList($where, $pageData['limit'], 'log_id desc');

        $this->assign('page', $pageData['html']);
        $this->assign('pageList', $list);
        $this->assign('pageParams', $urlParam);
        $this->assign('type', $type);
        $this->memberDisplay();
    }

}